package com.ytjj.qmyx.admin.controller.supplyChain;


import com.alibaba.fastjson.JSONObject;
import com.ytjj.common.utils.HttpClientUtil;
import com.ytjj.qmyx.admin.config.SupplyApiConfig;
import com.ytjj.qmyx.admin.model.request.DelayedRegionRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 *
 */
@Slf4j
@RestController
@RequestMapping("/delayedRegion")
public class DelayedRegionController {

    @Autowired
    private SupplyApiConfig supplyApiConfig;

    @GetMapping("/list")
    public String list(@RequestParam(required = false,defaultValue = "1") Integer pageNum,
                       @RequestParam(required = false,defaultValue = "10") Integer pageSize){
        Map<String,String> map = new HashMap<>();
        map.put("pageNum",pageNum.toString());
        map.put("pageSize",pageSize.toString());
        String s = HttpClientUtil.doGet(supplyApiConfig.getUrl() + "/delayedRegion/list", map, supplyApiConfig.getHeadsMap());
        return s;
    }

    @PostMapping("/update")
    public String update(@RequestBody DelayedRegionRequest request){
        log.info("===========参数==========={}",JSONObject.toJSONString(request));
        String s = HttpClientUtil.doPostJson(supplyApiConfig.getUrl() + "/delayedRegion/update",
                JSONObject.toJSONString(request), supplyApiConfig.getHeadsMap());
        return s;
    }
}
